package chemical_formula.client;

import chemical_formula.interpreter.Judgment;
import chemical_formula.interpreter.Lexer;
import chemical_formula.interpreter.Parser;
import chemical_formula.val.AST;
import chemical_formula.val.EqualOp;

import java.util.Scanner;

public class Client {
    public static void test1() throws Exception {
        Scanner scanner = new Scanner(System.in);
        String text = scanner.nextLine();
        Lexer lexer = new Lexer(text);
        Parser parser = new Parser(lexer);
        AST ast = parser.parse();
        Judgment judgment = new Judgment();
        System.out.println(judgment.judge((EqualOp) ast));
    }
    public static void test2() throws Exception {
        Scanner scanner = new Scanner(System.in);
        int t = Integer.parseInt(scanner.next());
        scanner.nextLine();
        for (int i = 0; i < t; i++) {
            String text = scanner.nextLine();
            Lexer lexer = new Lexer(text);
            Parser parser = new Parser(lexer);
            AST ast = parser.parse();
            Judgment judgment = new Judgment();
            System.out.println(judgment.judge((EqualOp) ast));
        }
    }
    public static void main(String[] args) throws Exception {
        // test1();
        test2();
    }
}
/*
11
H2+O2=H2O
2H2+O2=2H2O
H2+Cl2=2NaCl
H2+Cl2=2HCl
CH4+2O2=CO2+ 2H2O
CaCl2+2AgNO3=Ca(NO3)2+2AgCl
3Ba(OH)2+2H3PO4=6H2O+Ba3(PO4)2
3Ba (OH)2+2H3PO4=Ba3(PO4)2+6H2O
4Zn+10HNO3=4Zn(NO3)2+NH4NO3+3H2O
4Au+8NaCN+2H2O+O2=4Na(Au(CN)2)+4NaOH
Cu+As=Cs+Au
* */
